<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html class="win-frame">
<head>
<title>${name_china}管理-新建${name_china}</title>
 <%@include file="/common/head.jsp" %>

 <!-- 上传下载插件 -->
 <link href="<%=request.getContextPath()%>/static/plugin/uploadify/style/uploadify.css" rel="stylesheet">
 <script src="<%=request.getContextPath()%>/static/plugin/uploadify/js/jquery.uploadify.js"></script>

<!-- 时间日期插件 -->
<link href="<%=request.getContextPath()%>/static/plugin/My97DatePicker/skin/default/datepicker.css" rel="stylesheet" >
<script src="<%=request.getContextPath()%>/static/plugin/My97DatePicker/WdatePicker.js"></script>

<!-- 下拉树插件 -->
<link href="<%=request.getContextPath()%>/static/plugin/zTree/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" >
<script src="<%=request.getContextPath()%>/static/plugin/zTree/js/jquery.ztree.all-3.5.min.js"></script>

<!--富文本插件 -->
<script src="<%=request.getContextPath()%>/static/plugin/ckeditor/ckeditor.js"></script>

<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/plugin/bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/plugin/bootstrap-3.3.7-dist/css/bootstrap-theme.min.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/plugin/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/image-server/style/style.css">
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/plugin/webuploader-0.1.5/webuploader.css">
<link href="<%=request.getContextPath()%>/static/plugin/webuploader-0.1.5/uploader.css" rel="stylesheet">
<%-- <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/styles/css/product.css"> --%>
<!-- <script type="text/javascript" src="<%=request.getContextPath()%>/static/plugin/jquery-3.2.1.min.js"></script> -->
<script type="text/javascript" src="<%=request.getContextPath()%>/static/plugin/webuploader-0.1.5/webuploader.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/plugin/webuploader-0.1.5/common.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/plugin/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<style>
.samecomplex{
	float:left;
	
	
}
.samecomplex>input{
    background:red;
	margin-left:3px;
}
.addtime{
	float: left;
    width: 99px;
    height: 29px;
    background: #0474c8;
    color: #fff;
    text-align: center;
    line-height: 29px;
    margin-left: 11px;
    cursor:pointer;
}
.inputime{
    float: left;
    border: solid 1px #ccc;
    height: 30px;
}
.addgroduct{
	width:120px;
	height:36px;
	background:#f86b67;
	color:#fff;
	line-height:36px;
	cursor:pointer;
	text-align:center;
}
/****蒙版*****/
.maskcon{
	width: 100%;
    height: 100%;
    position: fixed;
    background: rgba(0,0,0,0.6);
    overflow-y: hidden;
    top: 0px;
    z-index:1;
    display:none;
}
.maskMain{
    width:95%;
    height: 100%;
    background: #fff;
    margin: 0 auto;
    margin-top: 50px;
}
.sameprosty{
	
}
/**规格**/
.addspecbut{
	width:73px;
	height:26px;
	line-height:26px;
	text-align:center;
	color:#fff;
	background:#45b854;
	cursor:pointer;
	float: left;
}
/*****规格蒙版******/
.specmask{
	width: 50%;
    height: 50%;
    background: rgba(0,0,0,0.7);
    z-index: 9;
    position: fixed;
    margin: 0 auto;
    margin-left: 20%;
    margin-top: 6%;
}
.closebut{
    width: 20px;
    height: 20px;
    background: red;
    float: right;
    margin: 6px;
    text-align: center;
    border-radius: 50%;
    font-size: 13px;
    color: #fff;
    line-height: 20px;
    cursor: pointer;
	
}
/****模块****/
.specelement{
    margin: 0 auto;
    text-align: center;
    color: #fff;
    margin-top: 109px;
}
.specinput{
    height: 30px;
    margin-left: 12px;
    color: #555;
    padding-left: 10px;
}
.specsure{
    width: 82px;
    height: 30px;
    background: #ff2040;
    text-align: center;
    line-height: 32px;
    margin: 0 auto;
    margin-top: 40px;
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
}
/***刷新***/
.refresh{
	float: left;
    width: 50px;
    height: 26px;
    background: #e82c0c;
    line-height: 26px;
    text-align: center;
    color: #fff;
    margin-left: 10px;
    cursor: pointer;
}
.procheckbox{
	float:left;
	margin-right: 10px;
}
.sameprobox{
    float: left;
    margin-left: 10px;
    line-height: 28px;
}

.splineclose{
	float: right;
    width: 20px;
    height: 20px;
    background: #000;
    color: #fff;
    font-style: normal;
    text-align: center;
    line-height: 20px;
    border-radius: 50%;
    cursor:pointer;
}
.specline{
	width:60%;

}
.specMain{
	overflow:auto;
		
}
.splinename{
	border-bottom:solid 1px #ccc;
}
.splinecon{
    overflow: auto;
    zoom: 1;
}
.samespline{
	float: left;
    margin-left: 10px;
}
.forclose{
    width: 15px;
    height: 15px;
    line-height: 15px;
    background: red;
    border-radius: 50%;
    text-align: center;
    color: #fff;
    float: right;
    margin-right: 11px;
    cursor: pointer;
}
/****规格展示*****/
.batch-update{
	line-height:30px;
	
}
.batch-update input[type=text]{
	height: 28px;
    width: 100px;
    margin-left: 8px;
    background-color: #fff;
    border-color: #d7d7d7;
    border: solid 1px #ccc;
    text-align:center;
}
.batch-submit{
    width: 80px;
    height: 30px;
    margin-left: 8px;
    border: 1px solid #d7d7d7;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
    background-color: #f8f8f8;
}
.list th{
    border: 1px solid #d2d2d2;
    line-height: 26px;
    padding: 0 2px;
    text-align: center;
    min-width: 90px;
}
.list tr:first-child {
    background-color: #f8f8f8;
}
.list td{
    border: 1px solid #d2d2d2;
    line-height: 26px;
    padding: 0 2px;
    text-align: center;
}
.list td input[type=text], .sku .list th input[type=text] {
    width: 100%;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-width: 0;
    background-color: #fff;
}
table, td {
    border-collapse: collapse;
    border-spacing: 0;
}
</style>
</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>${name_china}管理</span>
            <span class="split"></span>
            <span>新建${name_china}</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="addForm" method="post">
  <div id="left" style="width:80%;float:left">
   
	 <div class="form-wrapper">
	    
		<div class="h4 distance-double">
	        <span class="h4-title"><i class="icon icon-setting"></i>商品SPU</span>
	        <span class="h4-border"></span>
	    </div>
	    
	    <!-- 隐藏传值商品分类id -->
	    <input type="hidden" id="codeid" name="codeid" value="${codeid}"/>
	    <input type="hidden" id="categoryCodeid" name="categoryCodeid" value="${codeid}"/>
	    
	     <input type="hidden" id="properNameAndVal" name="properNameAndVal" value=""/>
	      <input type="hidden" id="goodssku" name="goodssku" value=""/>
	    
	    <input type="hidden" id="resultMap" name="resultMap" value=""/>
	    
	     <div class="form-cont" id="afterSku">
	        <p class="form-cont-title"><span class="field-required">*</span>商品编码</p>
	        <input type="text" id="spuNum" name="spuNum" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[100]']"/> 
	        <div >
				<p style="color:red">如不填写，可点击<a onclick="autoCreate()" style="cursor: pointer;">自动生成</a></p>
			</div>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>商品名称</p>
	        <input type="text" id="goodsName" name="goodsName" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[300]']"/> 
	     </div>
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>商品货号</p>
	        <input type="text" id="goodsAtrno" name="goodsAtrno" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[500]']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>商品公司来源</p>
	        <input type="text" id="companyId" name="companyId" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[500]']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>商品来源</p>
	        <input type="text" id="goodsSource" name="goodsSource" class="summer-input summer-validatebox"  data-validatebox="validType:['required','maxLength[500]']"/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">上市时间</p>
	        <input type="text" id="marketDate" name="marketDate" class="summer-input summer-validatebox"  onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/> 
	     </div>
	      <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>分类</p>
	        <input type="text" id="category" name="category" value="${categoryName}" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[300]']" readonly/> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title"><!-- <span class="field-required">*</span> -->商品品牌</p>
	        <input type="text" id="brandId" name="brandId" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[300]']"/> 
	     </div>
	      <div class="form-cont">
	        <p class="form-cont-title">商品发货时间规格</p>
	        <input type="text"  id="goodsDeliveryTimeSpec" name="goodsDeliveryTimeSpec" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[50]']"/>
	     	<!-- <div class="addtime">添加时间</div> -->
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">是否推荐</p>
	        <div class="complex">
	        	<div class="samecomplex"><input type="radio" value="1"  name="isRecommend" class="isRecommend" checked>是</div>
	        	<div class="samecomplex" style="margin-left:10px"><input type="radio" value="0"  name="isRecommend" class="isRecommend">否</div>
	        </div>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">积分抵扣</p>
	        <div class="complex">
	        	<div class="samecomplex"><input type="radio" value="1"  name="isJifenExchange" class="isJifenExchange" checked>是</div>
	        	<div class="samecomplex" style="margin-left:10px"><input type="radio" value="0"  name="isJifenExchange" class="isJifenExchange">否</div>
	        </div>
	     </div>
	     <div class="form-cont">
	        <p class="form-cont-title">是否使用系统红包</p>
	        <div class="complex">
	        	<div class="samecomplex"><input type="radio" value="1"  name="isSysCoupon" class="isSysCoupon" checked>是</div>
	        	<div class="samecomplex" style="margin-left:10px"><input type="radio" value="0"  name="isSysCoupon" class="isSysCoupon">否</div>
	        </div>
	     </div>
	     <div class="form-cont">
	        <p class="form-cont-title">是否使用商品红包</p>
	        <div class="complex">
	        	<div class="samecomplex"><input type="radio" value="1"  name="isGoodsCoupon" class="isGoodsCoupon" checked>是</div>
	        	<div class="samecomplex" style="margin-left:10px"><input type="radio" value="0"  name="isGoodsCoupon" class="isGoodsCoupon">否</div>
	        </div>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">是否精选</p>
	        <div class="complex">
	        	<div class="samecomplex"><input type="radio" value="1"  name="isJingping" class="isJingping" checked>是</div>
	        	<div class="samecomplex" style="margin-left:10px"><input type="radio" value="0"  name="isJingping" class="isJingping" checked>否</div>
	        </div>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">是否爆款</p>
	        <div class="complex">
	        	<div class="samecomplex"><input type="radio" value="1"  name="isHot" class="isHot" >是</div>
	        	<div class="samecomplex" style="margin-left:10px"><input type="radio" value="0"  name="isHot" class="isHot" checked>否</div>
	        </div>
	     </div>
	     <div class="form-cont">
	        <p class="form-cont-title">是否特卖</p>
	        <div class="complex">
	        	<div class="samecomplex"><input type="radio" value="1"  name="isSpecial" class="isSpecial" checked>是</div>
	        	<div class="samecomplex" style="margin-left:10px"><input type="radio" value="0"  name="isSpecial" class="isSpecial" checked>否</div>
	        </div>
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">是否正品保证</p>
	        <div class="complex">
	        	<div class="samecomplex"><input type="radio" value="1"  name="isQualityAssurance" class="isQualityAssurance" checked>是</div>
	        	<div class="samecomplex" style="margin-left:10px"><input type="radio" value="0"  name="isQualityAssurance" class="isQualityAssurance">否</div>
	        </div>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">是否包邮</p>
	        <div class="complex">
	        	<div class="samecomplex"><input type="radio" value="1"  name="isFreePost" class="isFreePost" checked>是</div>
	        	<div class="samecomplex" style="margin-left:10px"><input type="radio" value="0"  name="isFreePost" class="isFreePost">否</div>
	        </div>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">是否准时到达</p>
	        <div class="complex">
	        	<div class="samecomplex"><input type="radio" value="1"  name="isOnTime" class="isOnTime" checked>是</div>
	        	<div class="samecomplex" style="margin-left:10px"><input type="radio" value="0"  name="isOnTime" class="isOnTime">否</div>
	        </div>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">是否七天无理由退货</p>
	        <div class="complex">
	        	<div class="samecomplex"><input type="radio" value="1"  name="isServenBack" class="isServenBack" checked>是</div>
	        	<div class="samecomplex" style="margin-left:10px"><input type="radio" value="0"  name="isServenBack" class="isServenBack">否</div>
	        </div>
	     </div>
	   
	      <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>商品主图</p>
	        <input type="hidden" id="mainImageUrl" name="mainImageUrl" data-validatebox="validType:['required','maxLength[300]']"/> 
		     <!-- <input type="text" id="mainImageUrl" name="mainImageUrl" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[300]']"/> -->
		  <!--   文件上传 -->
	     	<div >
				<div id="mainImageUrlFileList" class="uploader-list"></div>
				<div id="mainImageUrlFilePicker">选择图片</div>
				<p style="color:red">建议高：159px；宽：159px</p>
			</div>
	     </div>
	     
	     
	     <div class="form-cont">
	        <p class="form-cont-title">商品视频</p>
	        <input type="hidden" id="videoUrls" name="videoUrls"/>
	        <!-- <input type="text" id="videoUrls" name="videoUrls" />  -->
	       <!-- 文件上传 -->
	     	<div >
				<div id="videoUrlsFileList" class="uploader-list"></div>
				<div id="videoUrlsFilePicker">选择视频</div>
				<p style="color:red">建议高：无限制；宽：375px</p>
			</div>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>商品轮播图</p>
	        <input type="hidden" id="bannerImageUrls" name="bannerImageUrls"/> 
	     	<!-- 文件上传 -->
	     	<div >
				<div id="fileList" class="uploader-list"></div>
				<div id="filePicker">选择图片</div>
				<p style="color:red">建议高：188px；宽：375px</p>
			</div>
	     </div>
	     
	     
	    <div id="show" display="none"></div>
		<div id="detail">
			<p class="first-caption"></p>
			<div class="first"></div>
			<p class="second-caption"></p>
			<div class="second"></div>
		</div>
		
		<!-- <button id="sub">提交</button> -->
		
		<div id="text"></div>
		<div class="batch-update">
       	   <label>批量填充</label>
       	   <input type="text" placeholder="价格" class="bacthprice">
       	   <input type="text" placeholder="佣金比例"  class="bacthrate">
       	   <input type="text" placeholder="佣金"  class="bacthbrokage">
       	   <input type="text" placeholder="库存" class="bacthstock">
       	   <input type="button" value="确定" class="batch-submit">
         </div>
		<table border="" cellspacing="" cellpadding="" class="list" id="table1">
			<thead>
				<tr>
					<th class="tab-first-caption"></th>
					<th class="tab-second-caption"></th>
					<th>价钱</th>
					<th>佣金比例</th>
					<th>佣金</th>
					<th>库存</th>
					<th>图片</th>
				</tr>
			</thead>
			<tbody id="tbody"></tbody>
		</table>
		
		<div id="goodsSkuAppend" class="form-cont">
       		 <p class="form-cont-title"><span class="field-required">*</span>商品图片</p>
       		 <!-- <input type="text" id="goodsSkuimage" name="goodsSkuimage" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[300]']"/> -->
       		 <select id="goodsSkuimage" class="summer-input summer-validatebox summer-validatebox-text">
       		 </select> 
   	    </div>
	    <div class="form-cont">
	        <input type="hidden" id="skuImagesUrls" name="skuImagesUrls"/> 
	     	<!-- 文件上传 -->
	     	<div >
				<div id="skuImagesfileList" class="uploader-list"></div>
				<div id="skuImagesPicker">选择图片</div>
				<p style="color:red">建议高：188px；宽：375px</p>
				<a id="uploadGoodsImages" class="btn btn-primary wave distance-right">确定上传</a>
			</div>
    	</div>
		
		 <div class="form-cont">
	        <p class="form-cont-title">进价</p>
	        <input type="text" id="orginPrice" name="orginPrice" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[500]']"/> 
	     </div>
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>价格</p>
	        <input type="text" id="wlPrice" name="wlPrice" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[500]']"/> 
	     </div>
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>总库存</p>
	        <input type="text" id="totalInventorys" name="totalInventorys" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[500]']"/>
	        <a id="totalCount" class="btn btn-primary wave distance-right">自动获取</a> 
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">红包价格</p>
	        <input type="text" id="couponMoney" name="couponMoney" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[500]']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">红包开始时间</p>
	        <input type="text" id="couponStartTime" name="couponStartTime" class="summer-input summer-validatebox"  onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">红包结束时间</p>
	        <input type="text" id="couponEndTime" name="couponEndTime" class="summer-input summer-validatebox"  onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" data-validatebox="validType:['maxLength[50]']"/> 
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">劵后价</p>
	        <input type="text" id="conPrice" name="conPrice" class="summer-input summer-validatebox"  data-validatebox="validType:['maxLength[500]']"/> 
	     </div>
		
	    	<div class="form-cont">
	       		 <p class="form-cont-title">推荐理由</p>
	       		 <textarea class="summer-textarea" id="goodsIntroduce" name="goodsIntroduce"></textarea>
		     </div>
			   
		      <div class="form-cont">
		       		 <p class="form-cont-title">产品参数</p>
		       		 <textarea class="summer-textarea" id="note" name="note"></textarea>
		      </div>
	    	
		    <div class="form-cont">
		        <p class="form-cont-title"><span class="field-required">*</span>商品详情图</p>
		        <input type="hidden" id="detailImageUrls" name="detailImageUrls"/>
		     	<div>
					<div id="detailImageUrlsFileList" class="uploader-list"></div>
					<div id="detailImageUrlsFilePicker">选择图片</div>
					<p style="color:red">建议高：无限制；宽：375px</p>
				</div>
		     </div>
		     
		      <div class="form-btn-wrapper" id="funcbar">
		        <a class="btn btn-normal" id="backBtn">关闭</a>
		     </div>
	     
  </div>
</div>
</form>
<script>

    //请求url
    var CONST_URL = {
        INIT_LIST: basePath + "${common_url}initGoodsSpu",
    	INIT_MAIN: basePath + "${common_url}init",
    	PRODUCT_PROPERTYS: basePath + "${common_url}getProductPropertys",
    	PRODUCT_PROPERTY_VALUES: basePath + "${common_url}getProductPropertyValues",
    	COMPANYS: basePath + "${common_url}companys",
       	ADD: basePath + "${common_url}add",
       	INIT_PROPERTY: basePath + "${common_url}initProperty",
       	GET_GOODS_BRAND: basePath + "${common_url}getGoodsBrand",
       	GET_GOODS_COMPANY: basePath + "${common_url}getGoodsCompany"
    };
    
    var  permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
    	
    	/* 初始化规格 */
    	$.ajax({
   			url: CONST_URL.INIT_PROPERTY,
   			type: 'POST',
   			dataType: 'json',
   			data:{
   				"codeid": $("#codeid").val()
   			},
   			success:function(data){
   					tab(data); //构建规格表格
         },  
        	error: function (XMLHttpRequest, textStatus, errorThrown) {
               // 状态码
               console.log(XMLHttpRequest.status);
               // 状态
               console.log(XMLHttpRequest.readyState);
               // 错误信息   
               console.log(textStatus);
           }
   	});
    		
    		//自动获取库存
	    	$("#totalCount").click(function(){
	    		var aa = 0;
	    		$("#tbody").find("tr").each(function(){
	    			var bb = $(this).find(".stock").val();
	    			aa = parseInt(aa)+parseInt(bb); ;
	    		})
	    		$("#totalInventorys").val(aa);
	    	});
    	
    	
    	//上传控件初始化
    	filePlugin("#bannerImageUrls","#filePicker","#fileList");
    	filePlugin("#videoUrls","#videoUrlsFilePicker","#videoUrlsFileList");
    	filePlugin("#mainImageUrl","#mainImageUrlFilePicker","#mainImageUrlFileList");
    	filePlugin("#detailImageUrls","#detailImageUrlsFilePicker","#detailImageUrlsFileList");
    	
    	filePlugin("#skuImagesUrls","#skuImagesPicker","#skuImagesfileList");
    	
    	//初始化下拉选项 商品来源
    	 $('#goodsSource').combobox({
            valueField : 'code',
            defaultValue:"yh",
            async:false,
            pleaseSelectFlag:false,
            textField : 'name',
            url : COMMON_URL.getCode + '?type=T_DM_GOODS_SOURCE'
        });

    	//初始化下拉选项  商品所属公司
    	 $('#companyId').combobox({
             url : CONST_URL.GET_GOODS_COMPANY, 
             valueField : 'id',
             async:false,
             textField : 'companyName'
         });
    	 
    	//初始化下拉选项 商品所属品牌
    	 $('#brandId').combobox({
             url : CONST_URL.GET_GOODS_BRAND ,
             valueField : 'id',
             async:false,
             textField : 'brandName'
         });
    	
    	//商品时间规格，初始化
    	 $('#goodsDeliveryTimeSpec').combobox({
             valueField : 'code',
             defaultValue:"24",
             async:false,
             pleaseSelectFlag:false,
             textField : 'name',
             url : COMMON_URL.getCode + '?type=T_DM_GOODS_DELIVERY_TIME'
         });
   	
     	$('#funcbar').prepend($.funcbar({
            type: 'button',
            data: permission,
            permit: ['${name_english}:addc','${name_english}:add']
        }));
    	
    	//保存按钮
    	/* $('#funcbar').on('click', 'a[data-permit="${name_english}:add"]', {isContinue: false},  submit); */
    	
    	//保存并添加按钮
    	$('#funcbar').on('click', 'a[data-permit="${name_english}:add"]', {isContinue: true},  submit);
    	
    	//返回按钮
    	$('#backBtn,#goBack').on('click',backMain);
    	
    	//确定上传按钮
    	$("#uploadGoodsImages").click(function(){
    		var goodsSkuimageValue = $("#goodsSkuimage").val(); //选择框的值
    		var str = "";
    		//获取上传空间里面的值
   			for (var i=0;i<$("#skuImagesfileList").length;i++) {
   				str += $("#skuImagesfileList")[i].innerHTML ;
  	   			}
    		//拼接到表格
   			$("#tbody").find("tr").each(function(){
				$(this).find("#"+goodsSkuimageValue+"11").html(str);
				
				$(this).find("."+goodsSkuimageValue+"").val($("#skuImagesUrls").val());
			})
			//删除上传控件里面的东西
    		$("#skuImagesfileList").find(".del").trigger("click");
    	})
    	
    });
    
  	//表单提交
    function submit(event) {
  		
    	var goodssku=[]
		$("#tbody").find("tr").each(function(){
			/* goodssku.push($(this).find('.firstValue').text()+","+$(this).find('.secondValue').text()+","+$(this).find('.price').val()+","+$(this).find('.comisrate').val()+","+$(this).find('.brokage').val()+","+$(this).find('.stock').val()+","+$(this).find('#'+$(this).find('.firstValue').text()+'').text()) */
			goodssku.push($(this).find('.firstValue').text()+","+$(this).find('.secondValue').text()+","+$(this).find('.price').val()+","+$(this).find('.comisrate').val()+","+$(this).find('.brokage').val()+","+$(this).find('.stock').val()+","+$(this).find('.'+$(this).find('.firstValue').text()+'').val())
		})
		$("#goodssku").val(goodssku);
  		
    	var goodsSku = $("#goodssku").val();
    	if(null == goodsSku){
    		alert("请选择属性");
    		return
    	}
  		
       $("#addForm").form({
      	 buttons : ['#saveBtn','#saveBtnContinue'],
           ajax: {
               url: CONST_URL.ADD,
               data:{
   				"couponMoney": $("#couponMoney").val(),
   				"couponStartTime":$("#couponStartTime").val(),
   				"couponEndTime":$("#couponEndTime").val(),
   				"properNameAndVal" : $("#properNameAndVal").val(),
   				"goodssku" : goodsSku
   			 }
           },
           onSubmitSuccess: function (data) {
          	 $.stip({
	                type:'ok',//显示类型 有info、 ok、 danger
	                text: '保存成功！',
	                onBeforeHide: function () {
	            	  var isContinue = event.data.isContinue;
	            	  
	            	  console.log(isContinue)
	            	  
	            	   console.log(data.data)
                 	  if (isContinue) {
                          backMain();
                 	  } else {
                 		 resetForm();
                 	  }
	               }
            	});
            }
       }).form("submit");
    }
  
    //保存并继续清空form
    function resetForm(){
        $('#bannerUrls').val('');
        $("#isMainView").remove();
        $("#isMain").val("0");
   	    
   	    $("#productOrginPrice").val('');
   	    $("#skuNum").val('');
    }
    
    //返回主页面
    function backMain() {
    	window.location.href = CONST_URL.INIT_LIST+"?codeid="+$("#codeid").val();
    }
    
   	//自动生成商品编码
    function autoCreate(){
    	var date = new Date();
        var seperator1 = "";
        var seperator2 = "";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
                +  date.getHours() + seperator2 + date.getMinutes()
                + seperator2 + date.getSeconds();
        $("#spuNum").val(currentdate);
    }
   
   
    
	function tab(str1){
		
		var res = str1;
    	var caption=[];
		var first=["m"];
		var second=[];
		
		var str="";
			/* str+='<input type="checkbox" checked="checked" id='+res.caption[i].id+' value='+res.caption[i].name+'><label >'+res.caption[i].name+'</label>' */
		$(".first-caption").text(res.caption[0].name);
		$(".second-caption").text(res.caption[1].name);
		
		$(".tab-first-caption").text(res.caption[0].name);
		$(".tab-second-caption").text(res.caption[1].name);
		$("#show").html(str)
		
		
		str="";
		for (var i=0;i<res.first.length;i++) {
			 str+='<input type="checkbox" id='+res.first[i].id+' value='+res.first[i].value+'><label >'+res.first[i].value+'</label>' 
		}
		$(".first").html(str)
		
		
		str="";
		for (var i=0;i<res.second.length;i++) {
			str+='<input type="checkbox" id='+res.second[i].id+' value='+res.second[i].value+'><label >'+res.second[i].value+'</label>'
		}
		$(".second").html(str)
		
		//做判断，尺寸，颜色等，如果选中下，下面对应的内容显示
		$("#show").on("click","input",function(){
			for (var i=0;i<$("#show>input").length;i++) {
				if($("#show>input").eq(i).prop("checked")){
					$("#detail>div").eq(i).show()
				}else{
					$("#detail>div").eq(i).hide()
				}
			}
			changeTable();
		})
		//修改表格数据
		function changeTable(){
			//console.log(first.length)
			var first_length=first.length;
			var second_length=second.length;
			
			var table_str="";
			
			for(var i=0 ; i < first_length ; i++){
				
				if(second_length==0){
					second[0]="未选择";
					return;
				}
				table_str+='<tr>'
					 +'<td rowspan='+second_length+'>'+first[i]+'</td>' 
					+'<td class="firstValue" style="display:none">'+firstValue[i]+'</td>'
					+'<td class="secondValue" style="display:none">'+secondValue[0]+'</td>'
					
					+'<td class="firstName" style="display:none">'+first[i]+'</td>'
					+'<td class="secondName">'+second[0]+'</td>'
					
					+'<td><input type="text" class="price" value=""></td>'
					+'<td><input type="text" class="comisrate" value=""></td>'
					+'<td><input type="text" class="brokage" value=""></td>'
					+'<td><input type="text" class="stock" value=""></td>'
					+'<td rowspan='+second_length+'><div id="'+firstValue[i]+'11"></div><input type="hidden" class="'+firstValue[i]+'" name="skuImagesPicker"/> </td>'
					+'</tr>'
							
				for (var j=1 ; j < second_length ; j++) {
					
					/* table_str+='<tr><td>'+second[j]+'</td>' */
					table_str+='<tr>'
					
					+'<td class="firstValue" style="display:none">'+firstValue[i]+'</td>'
					+'<td class="secondValue" style="display:none">'+secondValue[j]+'</td>'
					
					+'<td class="firstName" style="display:none">'+first[i]+'</td>'
					+'<td class="secondName">'+second[j]+'</td>'
					
					+'<td><input type="text" class="price" value=""></td>'
					+'<td><input type="text" class="comisrate" value=""></td>'
					+'<td><input type="text" class="brokage" value=""></td>'
					+'<td><input type="text" class="stock" value=""></td>'
					+'<td style="display:none"><input type="hidden" class="'+firstValue[i]+'" name="skuImagesPicker"/> </td>'
					+'</tr>'
				}
			}
			
			$("#tbody").html(table_str)
		}
		//最后提交的信息
		$("#sub").on("click",function(){
			if($("#show").is(":visible")  ){
				if(caption.length==0){
					alert("你商品规格没有设置")
				}else if(first.length==0){
					alert("你还没有设置尺寸")
					
				}else if(second.length==0){
					alert("你还没有设置颜色")
					
				}else{
					console.log("选中的规格是"+caption+"</br>选中的尺寸是"+first+"</br>选中中颜色是"+second)
				}
			}
		})
		
		$("#detail").on("click","input",function(){
			checkbox();
			changeTable();
		})
		
		function checkbox(){
			if($("#show").is(":visible") ){
				caption=[];
				for (var i=0;i<$("#show>input").length;i++) {
				if($("#show>input").eq(i).prop("checked")){
					caption.push($("#show>input").eq(i).val())
					}
				}
			}
			
			properNameAndVal=[];
			/* 父类点解复选框 */
			if($(".first").is(":visible")  ){
				first=[]
				firstValue = []
				
				/* var checkedNum = $(".first>input:checked").length; //所选择的个数
				var xhNum = 0; //判断循环几次 */
				
				/* var goodsSkuimage = "["; */
				var strImSele = "";
				for (var i=0;i<$(".first>input").length;i++) {
					if($(".first>input").eq(i).prop("checked")){
						first.push($(".first>input").eq(i).val())
						firstValue.push($(".first>input").eq(i).attr("id"))
						properNameAndVal.push(res.caption[0].id+","+res.caption[0].name+","+$(".first>input").eq(i).attr("id")+","+$(".first>input").eq(i).val())
						
						strImSele += "<option value=\""+$(".first>input").eq(i).attr("id")+"\">"+$(".first>input").eq(i).val()+"</option>";
						/* goodsSkuimage+="{\"name\""+":\""+$(".first>input").eq(i).val()+"\",";
						goodsSkuimage+="\"id\""+":\""+$(".first>input").eq(i).attr("id")+"\""; */
						/*xhNum++; 
						 if(xhNum <checkedNum){
							goodsSkuimage+="},";
						}else if(checkedNum = xhNum){
							goodsSkuimage+="}";
						} */
					}
				}
			
				$('#goodsSkuimage').html(strImSele);
				/* goodsSkuimage+="]"; */
				/* goods(strImSele); */
				function goods(goodsSkuimage){
					 
					 /* $('#goodsSkuimage').remove();
					 $("#goodsSkuAppend").find("summer-combobox").remove();
					
					 $("#goodsSkuAppend").append('<input type="text" id="goodsSkuimage" name="goodsSkuimage" class="summer-input summer-validatebox"/>');
					 
			    	 $('#goodsSkuimage').combobox({
			            data :  JSON.parse(goodsSkuimage) ,
			            textField : 'name',
			    	 	valueField : 'id'
			        });	 */
					
				}
			}
			
			/* 子类点解复选框 */
			if($(".second").is(":visible")  ){
				second=[];
				secondValue=[];
				for (var i=0;i<$(".second>input").length;i++) {
					if($(".second>input").eq(i).prop("checked")){
						second.push($(".second>input").eq(i).val())
						secondValue.push($(".second>input").eq(i).attr("id"))
						
						properNameAndVal.push(res.caption[1].id+","+res.caption[1].name+","+$(".second>input").eq(i).attr("id")+","+$(".second>input").eq(i).val())
						
						$("#properNameAndVal").val(properNameAndVal);
					}
				}
			}
		}
 	}
    
    $(".batch-submit").on('click',function(){
		var bacthprice = $(".bacthprice").val();
		var bacthrate = $(".bacthrate").val();
		var bacthbrokage = $(".bacthbrokage").val();
		var bacthstock = $(".bacthstock").val();
		
		$("#tbody").find("tr").each(function(){
			$(this).find(".price").val(bacthprice);
			$(this).find(".comisrate").val(bacthrate);
			$(this).find(".brokage").val(bacthbrokage);
			$(this).find(".stock").val(bacthstock);
		})
	})
	
    
</script>
</body>
</html>